<template>

        <el-dialog
                :before-close="handleDialogClose"
                v-bind="$attrs"
                v-on="$listeners"
                @open="onOpen"
                :title="title"
                :close-on-click-modal="false"
                width="30%"
        >
            <span>是否执行删除操作？确认删除后无法恢复。</span>
            <span slot="footer" class="dialog-footer">
    <el-button @click="cancel">取 消</el-button>
    <el-button type="primary" @click="submit">确 定</el-button>
  </span>
        </el-dialog>


</template>

<script>
    export default {
        name: "delForm",
        props:['delDialogVisile','form','title'],
        data(){
            return{
                delTitleMap:{
                    tableDelTile:'删除餐桌',
                }
            }
        },
        methods:{
            handleDialogClose(){
                this.$emit('onclose')
            },
            onOpen(){

            },
            cancel(){
                this.$emit('onclose')
            },
            deleteData(url,obj){
                this.axios({
                    url:url,
                    data:obj,
                    method:'post'
                })
                    .then(data=>{
                        console.log(data)
                    if (data.data.code==200){
                        this.$message({
                            type:'success',
                            message:'删除餐桌成功'
                        })
                        this.$emit('onclose',true)
                    }else {
                        this.$message({
                            type:'error',

                            message:'餐桌在使用中无法删除'
                        })
                        this.$emit('onclose',true)
                    }
                })

            },
            submit(){
                console.log('点击确认点击确认点击确认')

                if (this.title==this.delTitleMap.tableDelTile){

                    console.log(this.form)
                    this.deleteData('/deleteFoodTableById',{id:this.form.id})
                }

            }
        }
    }

</script>

<style lang="less" scoped>

</style>